//
//  OSWebViewController.m
//  百思不得姐
//
//  Created by PushMeBaby on 16/3/7.
//  Copyright © 2016年 CoderC. All rights reserved.
//

#import "OSWebViewController.h"
#import <NJKWebViewProgress.h>
@interface OSWebViewController ()
@property (weak, nonatomic) IBOutlet UIWebView *wenView;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *goBackItem;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *goForwardItem;
@property (weak, nonatomic) IBOutlet UIProgressView *progressView;

@property (nonatomic,strong)NJKWebViewProgress *progress;


@end

@implementation OSWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.progress = [[NJKWebViewProgress alloc]init];
    self.wenView.delegate = self.progress;
    __weak typeof (self)weakSelf = self;
    
    self.progress.progressBlock = ^(float progress) {
        weakSelf.progressView.progress = progress;
        
        weakSelf.progressView.hidden = (progress == 1.0);
    };
    
    self.progress.webViewProxyDelegate = self;
    
    [self.wenView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
    
    
    
    
}
- (IBAction)goBack:(id)sender {
    [self.wenView goBack];
}
- (IBAction)refresh:(id)sender {
    [self.wenView reload];
}

- (IBAction)forward:(id)sender {
    [self.wenView goForward];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - <UIWebViewDelegate>
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    self.goBackItem.enabled = webView.canGoBack;
    self.goForwardItem.enabled = webView.canGoForward;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
